package com.tao.erp.goods.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tao.erp.goods.pojo.Supplier;
import com.tao.erp.goods.service.SupplierService;

@Controller
@RequestMapping("/supplier")
public class SupplierAction {

	@Autowired
	private SupplierService supplierService;
	
	/**
	 * 异步查询Supplier集合
	 * @param supplier
	 * @return
	 */
	@RequestMapping("/selectSupplierList.action")
	@ResponseBody
	public List<Supplier> selectSupplierList(Supplier supplier){
		System.out.println(supplier);
		List<Supplier> list = supplierService.selectSupplierList(supplier);
		return list;
	}
	
	/**
	 * 通过id删除Supplier
	 * @param uuid
	 * @return
	 */
	@RequestMapping("/deleteSupplier.action")
	public String deleteSupplier(String uuid){
		int i = supplierService.deleteSupplierById(Integer.parseInt(uuid));
		System.out.println(i);
		System.out.println(uuid);
		System.out.println("123123");
		return "/jsp/goods/supplier.jsp";
	}
	
	/**
	 * 通过id查询单个Supplier
	 * @param uuid
	 * @param model
	 * @return
	 */
	@RequestMapping("/selectSupplierById.action")
	public String selectSupplierById(String uuid,Model model){
		Supplier supplier = supplierService.selectSupplierById(Integer.parseInt(uuid));
		model.addAttribute("supplier", supplier);
		return "/jsp/goods/supplierupdate.jsp";
	}
	
	/**
	 * 添加Supplier
	 * @param supplier
	 * @return
	 */
	@RequestMapping("/insertSupplier.action")
	public String insertSupplier(Supplier supplier){
		int i = supplierService.insertSupplier(supplier);
		System.out.println(i);
		return "/jsp/goods/supplier.jsp";
	}
	
	/**
	 * 修改Supplier通过id
	 * @param supplier
	 * @return
	 */
	@RequestMapping("/updateSupplier.action")
	public String updateSupplier(Supplier supplier){
		int i = supplierService.updateSupplier(supplier);
		System.out.println(i);
		return "/jsp/goods/supplier.jsp";
	}
	
}
